﻿using Newtonsoft.Json;
using System;


namespace Hx.ADSyncPlatform.Infrastructure.Converter
{
    public class BooleanConverter : Newtonsoft.Json.JsonConverter
    {


        public override bool CanConvert(Type objectType)
        {
            return objectType == typeof(string);
        }


        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {

            return reader.Value.ToString() == "1";
        }

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            writer.WriteValue((bool)value ? 1 : 0);



        }
    }
}
